package com.rwcw.admin.config.engine;

import com.rw.engine.frequency.interceptor.FrequencyInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 频率限制器
 */
@Configuration
public class FrequencyConfig implements WebMvcConfigurer {
    @Bean
    public FrequencyInterceptor getFrequencyInterceptor() {
        return new FrequencyInterceptor();
    }

    /**
     * 添加权限校验器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(getFrequencyInterceptor()).addPathPatterns("/**");
    }
}
